package com.bh.fallback.factory;

import com.bh.bean.User;
import com.bh.remote.UserRemoteClient;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Wang
 * @version 1.0
 * @date 2022/6/9 21:15
 */
@Component
public class UserFallbackFactory implements FallbackFactory<UserRemoteClient> {
    @Override
    public UserRemoteClient create(Throwable cause) {
        System.out.println("降级原因"+cause);
        return new UserRemoteClient() {
            @Override
            public Map queryUser(String id) {
                Map map=new HashMap();
                map.put("code",0);
                map.put("msg","工厂降级处理");
                return map;
            }

            @Override
            public void login(String username, String password) {

            }

            @Override
            public void testGetMap(Map map) {

            }

            @Override
            public void testPostMap(Map map) {

            }

            @Override
            public void testPostUser(User user) {

            }

            @Override
            public void testStringQueryMap(Map map) {

            }

            @Override
            public void testStringQueryUser(User user) {

            }
        };
    }
}
